#!/usr/bin/python
# - coding: UTF-8 -*-

#引入turtle函数
import turtle


#建立颜色数组
color = ["white","black","red","purple","green","blue","yellow",""]

#画图速度
turtle.speed(4)



#六边形
turtle.pensize(1)
turtle.color(color[0])      #定义为白色，防止点移动过程划线
turtle.goto(0,0)            #初始坐标
turtle.goto(0,50)           #坐标移动
turtle.right(120)
turtle.color(color[1])
for a in range(6):          #画边循环
    turtle.forward(90)
    turtle.right(60)

#六角星
turtle.pensize(1)
turtle.color(color[1])      #线色位黑色
turtle.right(30)
for b in range(3):
    turtle.forward(156)
    turtle.right(120)       #第一个倒等边三角
turtle.right(330)
turtle.color(color[1])
turtle.forward(90)
turtle.right(90)
for b in range(3):          #第二个倒等边三角
    turtle.forward(156)
    turtle.right(120)
'''两个等边三角相结合位六角星'''

#小六角星
'''以同样的方式，不同的长度来画'''
turtle.forward(104)
turtle.right(90)
for b in range(3):
    turtle.forward(90)
    turtle.right(120)
turtle.left(30)
turtle.forward(52)
turtle.right(90)
for b in range(3):
    turtle.forward(90)
    turtle.right(120)


#上色
'''通过fill来实现'''

#红三角
'''红三角的画图过程较为笨拙，但黄三角有了一定改进'''
turtle.begin_fill() 
turtle.left(90)
turtle.fillcolor(color[2])      #颜色定义为红色
for b in range(3):
    turtle.forward(52)
    turtle.right(120)
turtle.end_fill()
turtle.left(120)
turtle.begin_fill()
turtle.fillcolor(color[2])
for b in range(3):
    turtle.forward(52)
    turtle.left(120)
turtle.end_fill()
for c in range(4):                  #这一步循环可作为整个红三角的涂色的，但没去改正，而是运用到黄三角上
    turtle.left(60)
    turtle.begin_fill()
    turtle.forward(52)
    for b in range(3):
        turtle.forward(52)
        turtle.left(120)
    turtle.end_fill()
#黄三角

'''调整笔的位置，使循环能顺利进行'''
turtle.left(150)
turtle.fillcolor(color[6])
turtle.forward(30)
turtle.right(180)
'''该循环上色所有黄三角'''
for c in range(6):
    turtle.left(60)
    turtle.begin_fill()
    turtle.forward(30)
    for b in range(3):
        turtle.forward(30)
        turtle.left(120)
    turtle.end_fill()
#小六边形
turtle.begin_fill()
turtle.fillcolor(color[5])
for c in range(6):
    turtle.left(60)
    turtle.forward(30)
turtle.end_fill()
#绿等腰三角
'''对黄三角与红三角的空隙，也就是等腰三角形，进行涂色'''

'''调整笔位置'''
turtle.forward(30)
turtle.left(90)
turtle.fillcolor(color[4])
'''开始涂色'''
for c in range(6):
    turtle.begin_fill()
    turtle.forward(52)
    turtle.left(150)
    turtle.forward(30)
    turtle.left(60)
    turtle.forward(30)
    turtle.left(150)
    turtle.forward(52)
    turtle.end_fill()
    turtle.left(60)
turtle.end_fill()
#紫等腰三角
'''调整笔位置'''
turtle.right(60)
turtle.forward(52)
turtle.left(90)
turtle.fillcolor(color[3])
'''开始涂色'''
for c in range(6):
    turtle.begin_fill()
    turtle.forward(90)
    turtle.left(150)
    turtle.forward(52)
    turtle.left(60)
    turtle.forward(52)
    turtle.left(150)
    turtle.forward(90)
    turtle.end_fill()
    turtle.left(60)
turtle.end_fill()

        

